package com.aistar.hotel.controller;

import com.aistar.common.util.IdWorker;
import com.aistar.common.vo.PageList;
import com.aistar.common.vo.Result;
import com.aistar.hotel.entity.HotelComment;
import com.aistar.hotel.service.HotelCommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by wubin on 2019/6/29.
 */
@RestController
public class HotelRoomController {

    @Autowired
    private HotelCommentService hotelCommentService;
    @Autowired
    private IdWorker idWorker;


    @GetMapping("/hotelroom/{pageNow}")
    public Result serch(PageList pageList){
        PageInfo<HotelComment> pageInfo = hotelCommentService.getPageInfo("",pageList.getPageNow(),4);
        Result result = new Result(true,20000,"分页成功",pageInfo);
        return result;
    }

    @GetMapping("/hotelcomment/{commentText}")
    public Result savecomment(HotelComment hotelComment){
        hotelComment.setCommentId(idWorker.nextId());
        hotelComment.setHotelCommentId(idWorker.nextId());
        hotelComment.setCommentKeyword("我很喜欢");
        hotelComment.setCommentRead("我很喜欢这个酒店，装饰的很好，内容很丰富");
        hotelComment.setCommentTime(new Date());
        hotelComment.setCommentPicturesSrc("xxx.jpg");
        hotelCommentService.save(hotelComment);
        System.out.println(hotelComment.getCommentText());
        System.out.println(hotelComment);
        Result result = new Result(true,20000,"保存成功");

        return result;





    }



}
